dojo.provide("msos.google");
dojo.require("msos.common");
msos.google.ad_display_tool=function(_1){
this.adj_pos_top=1;
this.adj_pos_left=3;
this.delay_ad_fade=3000;
this.delay_ad_rotate=20000;
this.fade_duration=500;
this.rotate_multiple=1.3;
this._display_html=[];
this._timeout_ref=null;
this._index=0;
var _2=this;
dojo.connect(_1,"onclick",null,function(_3){
_3.preventDefault();
_3.stopPropagation();
if(_2._timeout_ref){
clearTimeout(_2._timeout_ref);
}
msos.common.event_debug(_3,"\ngoogle_ad_display_tool:\nCleared timeouts");
});
fade_in_out_func=function(){
_2._index=_2._display_html[_2._index+1]?_2._index+1:0;
var _4={node:_1,duration:_2.fade_duration};
var _5=function(){
dojo.fadeIn(_4).play();
};
var _6={node:_1,duration:_2.fade_duration,onEnd:function(){
_1.innerHTML=_2._display_html[_2._index];
setTimeout(_5,_2.fade_duration+100);
}};
dojo.fadeOut(_6).play();
_2._timeout_ref=setTimeout(fade_in_out_func,_2.delay_ad_rotate);
if(_2._index==0){
_2.delay_ad_rotate*=_2.rotate_multiple;
}
};
this.start_fade_in_out=function(){
var _7=dojo.query("iframe")||[];
var _8=new RegExp("google_ads_frame");
var _9=new RegExp("googleads.g.doubleclick");
for(var i=0;i<_7.length;i++){
if(_8.test(_7[i].id)||_9.test(_7[i].src)){
msos.common.set_popup_position(_7[i],_1,{adj_left:_2.adj_pos_left,adj_top:_2.adj_pos_top});
var _b=_7[i].parentNode;
var _c=_b.innerHTML;
var _d=_c.indexOf("<iframe");
_c=_c.substring(_d);
_2._display_html.push(_c);
}
}
if(djConfig.msos_content=="xml"){
console.warn("google_ad_display_tool - Not available (as of 2/13/09) in an xml page!");
}
if(_2._display_html.length>0){
var _e=_1.innerHTML;
_2._display_html.unshift(_e);
console.debug("google_ad_display_tool -> found "+(_2._display_html.length-1)+" google iframes");
_2._timeout_ref=setTimeout(fade_in_out_func,_2.delay_ad_fade);
}else{
console.warn("google_ad_display_tool - Found no iframes");
}
};
};

